{% macro render_form(form,url) %}
<form method='POST' action="{{ url }}">
    {{ form.csrf_token }}
    {% for field in form %}
       {% if field.type == 'CSRFTokenField' %}
       {{ '' }}
       {% elif field.type == 'SubmitField' %}
       {{ form.submit(class='btn btn-primary',type='submit') }}
       {% elif field.type == 'BooleanField' %}
       <div class="checkbox">
           <label>{{ field() }} {{ field.label.text }}</label>
       </div>
       {% else %}
       <div class="form-group {% if field.errors %}has-error{% endif %}">
           {{ field.label }} {{ field(class="form-control") }}
           {% if field.errors %}
             {% for error in field.errors %}
             <span class="help-block">{{ error }}</span>
             {% endfor %}
           {% endif %}
       </div>
       {% endif %}
    {% endfor %}
 </form>
 {% endmacro %}

 {% macro render_pagination(patination, endpoint) %}
 <nav class="nav-pagination" aria-label="Page navigation">
     <ul class=pagination>
         <li{% if not pagination.has_prev %} class="disabled"{% endif %}><a<href="{{url_for(endpoint, page=pagination.prev_num) if pagination.has_prev else '#'}}">&laquo;</a></li>
         {% for page in patination.iter_pages() %}
             {% if page %}
                 {% if page != pagination.page %}
                 <li><a href="{{ url_for(endpoint, page=page) }}">{{ page }}</a></li>
                 {% else %}
                 <li class="active"><a href="#">{{page}} <span class="sr-only">(current)</span></a></li>
                 {% endif %}
             {% endif %}
          {% endfor %}
          <li{% if not pagination.has_next %} class="disabled"{% endif %}><a href="{{url_for(endpoint, page=pagination.next_num) if pagination.has_next else "#"}}">&raquo;</a></li>
      </ul>
  </nav>
  {% endmacro %}


{% macro render_company(company) %}
<div class="col-sm-6 col-md-3 company-item">
  <div class="thumbnail">
    <img src="{{ company.detail.logo }}" width="100" height="100" alt="...">
    <h3>{{ company.name }}</h3>
    <p>{{ company.detail.field }}</p>
  <hr>
  <p>在招职位:{{ company.jobs.count() }}</p>
</div>
</div>
{% endmacro %}


{% macro render_pagination(pagination, endpoint) %}
<nav class="nav-pagination" aria-label="Page navigation">
<ul class=pagination>
  <li{% if not pagination.has_prev %} class="disabled"{% endif %}><a href="{{url_for(endpoint, page=pagination.prev_num) if pagination.has_prev else '#'}}">&laquo;</a>
</li>
{% for page in pagination.iter_pages() %}
  {% if page %}
  {% if page !=pagination.page %}
  <li><a href="{{ url_for(endpoint, page=page) }}">{{ page }}</a></li>
  {% endif %}
{% else %}
  <span class=ellipsis>?</span>
{% endif %}
{% endfor %}
<li{% if not pagination.has_next %} class="disabled"{% endif %}><a href="{{url_for(endpoint, page=pagination.next_num) if pagination.has_next else '#'}}">&raquo;</a></li>
</ul>
</nav>
{% endmacro %}


{% macro render_job(job) %}
<div class="col-sm-6 col-md-4">
  <div class="job-box">
    <div class="caption">
      <b>{{ job.name }}</b>
      <p>经验{{ job.experience_requirement }} {% if job.experience_requirement != '不限' %}年{% endif %}学历{{ job.degree_requirement }}</p>
      {% for tag in job.tag_list %}
      <span class="label label-default">{{ tag }}</span>
      {% endfor %}  
    </div>
    <hr>
    <div class="media">
      <div class="media-left">
        <a href="#">
          <img class="media-object" src="{{ job.company.detail.logo }}" width="40" height="40" alt="...">
        </a>
      </div>
      <div class="media-body"><h4 class="media-heading">{{ job.company.name }}</h4>
        <span class="company-meta">{{ job.company.detail.field }}/{{ job.company.detail.finace_stage }}/{{ job.company.detail.location }}</span>
      </div>
    </div>
  </div>
</div>
{% endmacro %}
